const assert = require("assert")

console.log("解构表达式");

const keyName = "title"

const goods = {
    title: "快来把我买走",
    price: 99.9
}


const shoppingCart = {}; // 如果这里丢失 ; ，则抛出异常

// 动态解构属性名
// 支持此类语法，但是要求其前后有 ;
({ [keyName]: shoppingCart[keyName] } = goods);

// ({ [keyName]: shoppingCart.title } = goods)

assert.equal(shoppingCart[keyName], goods[keyName])

const array = [1,2,3,4,5]

// 数组解构，顺便跳过第1，2，5个元素
const [,,three,four,] = array

assert.equal(three,3)
assert.equal(four,4)

